package br.com.caelum.vraptor.controller;

import java.util.List;

import javax.inject.Inject;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.dao.AlunoDAO;
import br.com.caelum.vraptor.dao.AvaliacaoAlunoDAO;
import br.com.caelum.vraptor.dao.AulaDAO;
import br.com.caelum.vraptor.dao.GenericDAO;
import br.com.caelum.vraptor.dao.GenericJPADAO;
import br.com.caelum.vraptor.entidades.AvaliacaoAluno;

@Controller
public class AvaliacaoAlunoController {
	
	@Inject
	private Result result;
	
	@Inject
	private GenericDAO<AvaliacaoAluno> dao;
	
	@Inject
	private AulaDAO aulaDAO;
	@Inject
	private AlunoDAO alunoDAO;
	public void add(){
		result.include("alunoList", alunoDAO.find());
		result.include("aulaList", aulaDAO.find());
	}
	
	
	public List<AvaliacaoAluno> list(){
		return dao.find();
		
	}
	
	
	public void save(AvaliacaoAluno avaliacaoAluno){
		
		dao.save(avaliacaoAluno);
		
		result.redirectTo(this).list();
	}
	
	public AvaliacaoAluno edit(Integer id){
		return dao.find(id);
	}
	
	public void delete(int id){
		AvaliacaoAluno avaliacaoAluno = new AvaliacaoAluno();
		avaliacaoAluno.setId(id);
		dao.delete(avaliacaoAluno);
		result.redirectTo(this).list();
	}
	
}
